#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int removeElement(int* nums, int numsSize, int val)
{
    if (numsSize == 1 && nums[0] == val)
        return 0;
    int left = 0;
    int right = numsSize - 1;
    int count = 0;
    while (left < right)
    {
        while (nums[right]==val&&left<=right)
        {
            right--;
            count++;
        }
        if (left >= right)
            return numsSize-count;
        while (nums[left] != val)
        {
            left++;
        }
        int tmp = 0;
        tmp = nums[left];
        nums[left] = nums[right];
        nums[right] = tmp;
        count++;
        left++;
        right--;

    }
    return numsSize - count;

}

int main()
{
    int nums[] = { 3,3 };
    int numsSize = sizeof(nums) / sizeof(nums[0]);
    int ret = removeElement(nums, numsSize, 3);
    int i = 0;
    for (i = 0; i < ret; i++)
    {
        printf("%d ", nums[i]);
    }
    return 0;
}